<template>
    <st-uni-loadmore ref="loadmoreref">
        <view class="activity-list">
            <uni-card v-for="(item,index) in listData" @click="goDetail(item)">
                <view class="uni-media-list">
                    <view class="uni-media-list-logo">
                        <image :src="item.titleUrl"></image>
                    </view>
                    <view class="uni-media-list-body">
                        <view class="uni-media-list-text-top font-size-md">{{item.title}}</view>
                        <view class="uni-media-list-text-body uni-text  font-size-sm">
                            {{$utils.date.dateFomatWeek(item.startTime)}}
                        </view>
                        <view class="uni-media-list-text-bottom uni-ellipsis font-size-sm">
                            <text>
                                {{item.introduced}}
                            </text>
                        </view>
                    </view>
                </view>
                <view class="uni-card-footer">
                  <view class="uni-card-link">{{item.participateTotal}}/{{item.participateLimitTotal}} 人
                  </view>
                    <view class="uni-card-link">
                      报名已截止{{item.isParticipate ? '(已报名)': '(未报名)'}}
                    </view>
                </view>
            </uni-card>
        </view>
    </st-uni-loadmore>
</template>

<script>
    import StUniLoadmore from "../../components/StUniLoadmore";

    export default {
        components: {StUniLoadmore},
        computed: {},
        data() {
            return {
                listData: []
            }
        },
        onPullDownRefresh() {
            this.loadData(true)
        },
        onReachBottom() {
            this.loadData(false)
        },
        onLoad() {

        },
        onReady() {
            this.loadData(true)
        },
        onTabItemTap(e) {
            uni.setStorageSync('tabItemIndex', e.index)
        },
        methods: {
            goDetail(data) {
                uni.navigateTo({
                    url: '/pages/activity/detail?id=' + data.id
                })
            },
            loadData(pullDownRefresh) {
                if (!this.$refs.loadmoreref) {
                    return
                }

                this.$refs.loadmoreref.loadData('/app/activity/history/getPage', {
                    pullDownRefresh: !!pullDownRefresh
                }).then(res => {
                    let content = res.data.records
                    if (pullDownRefresh) {
                        this.listData = content
                    } else {
                        this.listData = this.listData.concat(content);
                    }
                })
            }
        },
        watch: {}
    }
</script>

<style>

    page {
        background-color: #F5F5F5;
    }

    /*.activity-list .uni-card {*/
    /*    margin: 10 upx 0 !important;*/
    /*}*/

    .activity-list .image {
        width: 100%;
    }
</style>
